<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>10_员工列表练习</title>
</head>
<body>
    <input type="text" id="i1" placeholder="请输入员工姓名">
    <input type="text" id="i2" placeholder="请输入员工工资">
    <input type="text" id="i3" placeholder="请输入员工岗位">
    <button onclick="f1()">添加员工</button>
    <hr>
    <table border="1px">
        <caption>员工表</caption>
        <tr>
            <td>姓名</td>
            <td>工资</td>
            <td>岗位</td>
        </tr>
    </table>
    <script>
        let arr = [];
        function f1(){
            let name = document.getElementById('i1').value;
            let sal = document.getElementById('i2').value;
            let job = document.getElementById('i3').value;
            console.log(name);
            let e = document.querySelector("table");
            let tr = document.createElement('tr');
            let td1 = document.createElement('td');
            let td2 = document.createElement('td');
            let td3 = document.createElement('td');
            td1.innerHTML = name;
            td2.innerHTML = sal;
            td3.innerHTML = job;
            tr.append(td1,td2,td3);
            e.append(tr);
            arr.push({
                name:name,
                salary:sal,
                job:job
            });
        }
    </script>
</body>
</html>